<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>上传歌曲</title>
</head>
<style>
  .container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 500px;
    padding: 20px;
    border: 1px solid #ccc;
    border-radius: 5px;
  }
  form input[type="text"],
  form select,
  form input[type="file"] {
    width: 100%;
    padding: 5px;
    margin-bottom: 10px;
    margin-top: 15px; /* 增加margin-top以将输入框往下移动 */
  }
  form button {
    background-color: #4CAF50;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
  }
</style>
<body>
  <div class="container">
    <form method="post" action="your-endpoint" enctype="multipart/form-data" id="myForm">
      歌名: <input type="text" name="videoName"><br>
      原作者：<input type="text" name="originalAuthor"><br>
      音乐类型:
        <select name="musicStyle" id="musicStyle">
          <option value="1">流行</option>
          <option value="2">摇滚</option>
          <option value="3">民谣</option>
          <option value="4">蓝调</option>
          <option value="5">爵士</option>
          <option value="6">funk</option>
          <option value="7">重金属</option>
          <option value="8">古典</option>
        </select><br>
        上传MV:<input type="file" name="MV" /><br>
        上传封面:<input type="file" name="cover" /><br>
      <!-- 其他表单字段 -->
      <button type="submit">提交</button>
  </form>
  </div>
  <script>
    const form = document.querySelector('#myForm')
    form.addEventListener('submit',(e)=>{
      e.preventDefault();
      const formData = new FormData(form);
        // 获取上传的文件信息
        const videoName = formData.get('videoName');
        const musicStyle = formData.get('musicStyle')
        const MV = formData.get('MV')
        const originalAuthor = formData.get('originalAuthor')
        const cover = formData.get('cover')
        const song = {
          "videoName":videoName,
          "originalAuthor":originalAuthor,
          "style":musicStyle,
          "MVFile":MV,
          "coverFile":cover
        }
        axios({
          url:'http://localhost:8080/private',
          method:"post",
          data:song,
          headers: {
            'Content-Type': 'multipart/form-data'
          }
        }).then(result => {
          console.log(result.data.data);
          form.reset()
        })
    })
  </script>
  <script src="../js/axios.min.js"></script>
</body>
</html>